//
//  YCRepresentResultCell.m
//  ttttt
//
//  Created by itclimb on 07/06/2017.
//  Copyright © 2017 itclimb.yuancheng.com. All rights reserved.
//

#import "YCRepresentResultCell.h"
#import <SDWebImage/UIImageView+WebCache.h>

@interface YCRepresentResultCell ()
//头像
@property (weak, nonatomic) IBOutlet UIImageView *icon;
//头部姓名
@property (weak, nonatomic) IBOutlet UILabel *topName;
//头部Vip
@property (weak, nonatomic) IBOutlet UILabel *topVipName;
//头部付款状态
@property (weak, nonatomic) IBOutlet UILabel *topState;
//姓名
@property (weak, nonatomic) IBOutlet UILabel *name;
//手机号
@property (weak, nonatomic) IBOutlet UILabel *phoneNum;
//配送状态
@property (weak, nonatomic) IBOutlet UILabel *state;
//物流编号
@property (weak, nonatomic) IBOutlet UILabel *logisticsNum;
//购买类型
@property (weak, nonatomic) IBOutlet UILabel *buyStyle;

@end

@implementation YCRepresentResultCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.icon.layer.masksToBounds = YES;
    self.icon.layer.cornerRadius = self.icon.bounds.size.width * 0.5;
    
}

//MARK: - 分发数据
- (void)setModel:(YCRepresentModel *)model{
    [self.icon sd_setImageWithURL:[NSURL URLWithString:model.HEADIMGURL] placeholderImage:[UIImage imageNamed:@"矢量智能对象"]];
    self.topName.text = model.NICKNAME;
    self.topVipName.text = model.MEMBER_NAME;
    self.name.text = model.PERSON_NAME;
    self.phoneNum.text = [model.PERSON_MOBILE stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
    
    if ([model.ORDER_STATUS isEqualToString:@"待付款"]) {
        model.ZT_FLAG = @"未发货";
        self.topState.textColor = RGB(253, 133, 38);
    }else if ([model.ORDER_STATUS isEqualToString:@"已付款"]){
        self.topState.textColor = RGB(82, 176, 7);
        if ([model.ZT_FLAG isEqualToString:@"自提"]){
            model.ZT_FLAG = @"自提";
        }else if ([model.ZT_FLAG isEqualToString:@"物流"]){
            if ([model.WL_CODE isEqualToString:@"0"]) {
                model.ZT_FLAG = @"未发货";
            }else{
                model.ZT_FLAG = @"已发货";
            }
        }
    }
    self.state.text = model.ZT_FLAG;
    
    if ([model.WL_CODE isEqualToString:@"0"]) model.WL_CODE = @"暂无";
    self.logisticsNum.text = model.WL_CODE;
    
    self.buyStyle.text = model.SALE_TYPE?:@"暂无";
    self.topState.text = model.ORDER_STATUS;
}

@end
